<?php

namespace App\Modules\Blog\Http\Controllers\Api;

use App\Modules\Blog\Models\Blog;
use App\Modules\Blog\Http\Resources\BlogResource;
use App\Modules\Blog\Http\Requests\BlogCreateRequest;
use App\Modules\Blog\Http\Requests\BlogUpdateRequest;
use App\Http\Controllers\Controller;

class BlogController extends Controller
{

    /**
     * @var Laoha\Modules
     */
    protected $module_slug = "blog";



    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

	$data = Blog::paginate(10);
	$data = BlogResource::collection($data);
	
	return $data->additional(json_ext(['module'=>get_module($this->module_slug)])); 
	//
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \App\Modules\Blog\Http\Requests\BlogCreateRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(BlogCreateRequest $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
	$data = Blog::find($id);
	$data = new BlogResource($data);
	
	return $data->additional(json_ext(['module'=>get_module($this->module_slug)])); 
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \App\Modules\Blog\Http\Requests\BlogUpdateRequest  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(BlogUpdateRequest $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
